<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title>
    <#include "/admin/include/head.htm">
    <#include "/admin/include/upload.ftl">
    <script type="text/javascript" src="${base}/resource/thirdparty/editor/kindeditor.js"></script>
    <script type="text/javascript" src="${base}/resource/js/input.js"></script>
    <script type="text/javascript">
        //更改eidtor插件本地上传目录为文章目录
        setting.uploadType = "intergralproduct";
        var shopclassTree = null;
        var selectCategory = null;
        $(function() {
            var mainform = $("#mainform");
            isTabValid();
            $("#tabcontainer input").attr("autocomplete", "off");
            //表单底部按钮
            LG.setFormDefaultBtn(f_cancel, function() {
                f_save(mainform, "b2c_intergral_shop_product");
            });

            $(".browserButton").browser({
                "createThumb" : 0, //创建缩略图
                "callback" : function(url, store_path) {
                    $(this).prev().val(store_path);
                },
                uploadType : 'intergral'
            }, function() {
                $.ligerDialog.close();
            });
            //标志editor编辑器图片本地上传目录
            setting.uploadType = "intergral";
            $("#shopClasstreeName").focus(function() {

                if(shopclassTree) {
                    shopclassTree.show();
                } else {
                    shopclassTree = $.ligerDialog.open({
                        url: '${base}/admin/b2c/intergral_shop_product/shopclassTree.jhtml',
                        left: $(this).offset().left,
                        top: $(this).offset().top,
                        height: 400,
                        width: null,
                        modal: true,
                        titie: '商品分类',
                        buttons: [{
                            text: '确定',
                            onclick: function(item, dialog) {
                                if(selectCategory) {
                                    selectCategory();
                                }
                            }
                        }, {
                            text: '取消',
                            onclick: function (item, dialog) {
                                dialog.hide();
                            }
                        }]
                    });
                }
            });

        });

    </script>
</head>
<#if !product??>
    <#assign isAdd = true />
<#else>
    <#assign isEdit = true />
</#if>
<body style="overflow:hidden;padding:10px;">
<form action="<#if isAdd??>${base}/admin/b2c/intergral_shop_product/save.jhtml<#else>${base}/admin/b2c/intergral_shop_product/update.jhtml</#if>" method="post" id="mainform" class="validate">
    <div id="tabcontainer" style="overflow:hidden;margin:3px;">
    <#if !isAdd??>
        <input type="hidden" name="id" value="${(product.id)!''}"/>
        <input type="hidden" name="sale_num" value="${(product.sale_num)!''}"/>
    </#if>
        <table class="table" style="width:100%;">
            <tr>
                <th>名称:</th>
                <td>
                    <input type="text" name="name" value="${(product.name)!''}"  maxlength="20"
                           class="formText {required: true, maxlength: 20, remote:'${base}/admin/b2c/intergral_shop_product/checkProductName.jhtml?oldName=${(product.name)!''}', messages: {remote: '名称已存在!'}}"/>
                </td>
            </tr>

            <tr>
                <th>商品分类：</th>
                <td>

                <@u.select headerKey="" headerValue="请选择..." listKey="id" listValue="name"  value="${((product.shopclass.id)!shopclass.id)!''}"
                name="shopclass.id"    class="{required: true}"   headerButtom="false" list=shopclassList />
                </td>
            </tr>

            <tr>
                <th>详情页展示图片:</th>
                <td>
                    <input type="input" value="${(product.litpic)!''}" name="litpic" class="formText"/>
                    <input type="button" value="选择图片" class="button browserButton">
                </td>
            </tr>

            <tr>
                <th>商品信息: </th>
                <td>
                    <textarea id="editor" name="content" class="editor" style="width: 100%; height: 100%">${(product.content)!''}</textarea>
                </td>
            </tr>
            <tr>
                <th>数量: </th>
                <td>
                    <input type="text" name="num" value="${(product.num)!''}"  maxlength="20"
                           class="{required: true}"       />
                </td>
            </tr>
            <tr>
                <th>价格: </th>
                <td>
                    <input type="text" name="price" value="${(product.price)!''}"  maxlength="20"  class="{required: true}"
                    />
                </td>
            </tr>
        </table>
    </div>
</form>
</body>
</html>